<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Unix)">
	<META NAME="CREATED" CONTENT="0;0">
	<META NAME="CHANGED" CONTENT="20101227;15065000">
	<STYLE TYPE="text/css">
	<!--
		@page { size: 8.27in 11.69in }
	-->
	</STYLE>
</HEAD>
<BODY LANG="en-US" DIR="LTR">
<P><BR><BR>
</P>
<P STYLE="text-decoration: none"><FONT SIZE=6 STYLE="font-size: 22pt"><B>Numerical
differentiation</B></FONT></P>
<P STYLE="text-decoration: none"><FONT SIZE=6 STYLE="font-size: 22pt"><B>jacobnnf</B></FONT></P>
<P ALIGN=JUSTIFY><FONT SIZE=4>Calculates the Jacobian matrix of an
n-dimensional function of <I>n </I>variables using forward
differences. j<I>acobnnf </I><SPAN STYLE="font-style: normal">computes
first order difference quotient approximations to the partial
derivatives.</SPAN></FONT></P>
<P ALIGN=JUSTIFY><BR><BR>
</P>
<P ALIGN=JUSTIFY><FONT SIZE=4><B><SPAN STYLE="font-style: normal">Example:
Can be run with F5 within the ScalaLab Editor (Ctrl-E to open the
editor)</SPAN></B></FONT></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">import
java.text.DecimalFormat;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">import numal.*;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">public class Test_jacobnnf
extends Object implements AE_jacobnnf_methods {</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">public static void
main(String args[]) {</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">int i;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double x[] = new double[3];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double f[] = new double[3];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">double jac[][] = new
double[3][3];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">Test_jacobnnf testjacobnnf =
new Test_jacobnnf();</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">x[1]=2.0; x[2]=1.0;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">testjacobnnf.funct(2,x,f);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">Analytic_eval.jacobnnf(2,x,f,jac,testjacobnnf);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">DecimalFormat fiveDigit = new
DecimalFormat(&quot;0.00000E0&quot;);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">System.out.println(&quot;The
calculated jacobian is:\n &quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(jac[1][1]) +
&quot; &quot; + </FONT>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(jac[1][2]) +
&quot;\n &quot; +</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(jac[2][1]) +
&quot; &quot; + </FONT>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">fiveDigit.format(jac[2][2]));</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
<P><BR><BR>
</P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">public double di(int i, int
n) {</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">return ((i == 1) ? 1.0e-5 :
1.0);</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">public void funct(int n,
double x[], double f[]) {</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">f[1]=x[1]*x[1]*x[1]+x[2];</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">f[2]=x[2]*10.0;</FONT></P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
<P><BR><BR>
</P>
<P><FONT SIZE=2 STYLE="font-size: 11pt">}</FONT></P>
</BODY>
</HTML>